<template>
  <view class="goods_item"  > 
            <!-- 商品左侧图片 -->
            <view class="goods_item_left">
          <!-- <radio  :checked="goods.goods_state"   v-if="flag"  @click="radioClickHandler(goods)"  checked color="#c00000"></radio> -->
             <checkbox   :checked="goods.goods_state"   v-if="flag"  @click="radioClickHandler(goods)"  checked color="#c00000" ></checkbox >
                 <image :src="goods.goods_small_logo || defaultPic" > </image>
            </view>
            <!-- 右侧信息区域 -->
            <view class="goods_item_right" @click='btn'>
                 <!-- 商品标题 -->
                   <view class="goods_name"> {{goods.goods_name}} </view>
                   <view class="goods_info_box">
                         <div class="goods_price">￥{{goods.goods_price | tofied}}</div>
                         <uni-number-box  v-if="flag" :min="1" :value="goods.goods_count" @change="numchange" ></uni-number-box>
                  </view>
            </view>
           
           
         </view>
</template>

<script>

	export default {
  
    // 接收list传来的数据
   
    props:{
        goods:{
            type: Object,
            defaul: {}
        },
        flag:{
          type:Boolean,
          default:false
        }
    },
		data() {
			return {
				// 默认的空图片
				    defaultPic: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png',
           
			};
		},
    created() {
    
    },
    methods:{
      radioClickHandler(goods){
        console.log(this.goods.goods_state,4888)
           // this.goods.goods_state = !this.goods.goods_state
        this.$emit('vidio-change',{
          goods_id:goods.goods_id,
          goods_state:!goods.goods_state
        })
      },
      // 监听表单值变化
      numchange(val){
        console.log(this.goods.goods_id,val,100000)
        this.$emit('numfun',{
          goods_id : this.goods.goods_id,
          goods_count : +val
        })
      },
      btn(){
        // console.log(this.goods,250)
      }
    
    },
    filters:{
      tofied(num){
        return Number(num).toFixed(2)
      }
    }
	}
</script>

<style lang="scss">
.goods_item{
  width:100%;
    display:flex;
      padding: 10px 5px;
      border-bottom: 1px solid #f0f0f0;
 
       .goods_item_left{
        margin-right: 5px;
        display:flex;
        align-items: center;
        radio{
          
        }
           image{
               width:100px;
               height:100px;
               display: block;
           }
       }
       .goods_item_right{
        width:100%;
          display:flex;
         flex-direction: column;
         justify-content: space-between;
         .goods_name{}
         .goods_info_box{
           display: flex;
           align-items:center;
           justify-content:space-between;
            .goods_price{
              color: red;
            }
         }
       }
  }
</style>
